//
//  CustomerTagSend.swift
//  Employee
//
//  Created by tancheng on 2018/7/23.
//  Copyright © 2018年 remotevillage. All rights reserved.
//

import Foundation
import SwiftyJSON

class CustomerTagCategoryModel: NSObject {
    
    
    //
    var categoryId: String
    var categoryName: String
    var tags: [CustomerTagModel]
    
    init(json: JSON) {
        
        categoryId = json["categoryId"].stringValue
        categoryName = json["categoryName"].stringValue
        tags = CustomerTagModel.array(from: json["tags"].arrayValue)
        
    }
    
   
    
    static func array(from jsonArray: [JSON]) -> [CustomerTagCategoryModel] {
        return jsonArray.map({CustomerTagCategoryModel.init(json: $0)})
    }
    
    
}

class CustomerTagModel: NSObject {
    
    var isSelected: Bool = false //是否选择
    var tagWidth: CGFloat = 0
    var itemWidth: CGFloat {
        return tagWidth + 20
    }
    var addItemWidth: CGFloat {
        return tagWidth + 52
    }
    var itemHeight: CGFloat = 38
    //
    var branchDefaultIcon: String
    var companyId: String
    var createTime: String
    var createdBy: String
    var devared: Bool
    var expand: Bool
    var icon: String
    var id: String
    var lastModifiedBy: String
    var lastModifiedDate: String
    var leaf: Bool
    var leafDefaultIcon: String
    var name: String
    var new: Bool
    var orgPath: String
    var parentId: String
    var parentIdPath: String
    var parentIds: String
    var root: Bool
    var rootDefaultIcon: String
    var separator: String
    var status: String
    var total: String
    var type: String
    var version: String
    var weight: String
    
    init(json: JSON) {
         branchDefaultIcon = json["branchDefaultIcon"].stringValue
         companyId = json["companyId"].stringValue
         createTime  = json["createTime"].stringValue
         createdBy  = json["createdBy"].stringValue
         devared  = json["devared"].boolValue
         expand  = json["expand"].boolValue
         icon = json["icon"].stringValue
         id = json["id"].stringValue
         lastModifiedBy = json["lastModifiedBy"].stringValue
         lastModifiedDate  = json["lastModifiedDate"].stringValue
         leaf  = json["leaf"].boolValue
         leafDefaultIcon  = json["leafDefaultIcon"].stringValue
         name  = json["name"].stringValue
         new  = json["new"].boolValue
         orgPath  = json["orgPath"].stringValue
         parentId  = json["parentId"].stringValue
         parentIdPath  = json["parentIdPath"].stringValue
         parentIds  = json["parentIds"].stringValue
         root  = json["root"].boolValue
         rootDefaultIcon  = json["rootDefaultIcon"].stringValue
         separator = json["separator"].stringValue
         status = json["v"].stringValue
         total = json["total"].stringValue
         type = json["type"].stringValue
         version = json["version"].stringValue
         weight = json["weight"].stringValue
        
        //
       tagWidth = UIFont.calculateWidth(font: GlobalConfig.system16Font, text: name)
        
        
    }
    
    static func array(from jsonArray: [JSON]) -> [CustomerTagModel] {
         return jsonArray.map({CustomerTagModel.init(json: $0)})
    }
    
    
}

struct CustomerTagSend {
    var customerId: String = ""
    var tagIds: String = ""
}
